package com.ge.modules.base.controller;

import java.util.List;

import com.ge.common.utils.R;
import com.ge.modules.base.service.TbDistrictService;
import com.ge.modules.entity.TbDistrictEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 区
 *
 * @author Luo
 * @email www.baidu.com
 * @date 2018-04-12 14:50:44
 */
@RestController
@RequestMapping("/loca/district")
public class TbDistrictController {

    @Autowired
    private TbDistrictService tbDistrictService;

    /**
     * 根据城市id来查询所有区
     */
    @RequestMapping("/list")
    public R list(@RequestParam("cityid") int cityid) {

        List<TbDistrictEntity> districtList = tbDistrictService.getList(cityid);

        return R.ok().put("districtList", districtList);
    }


    /**
     * 根据区的id来查询区的信息
     */
    @RequestMapping("/info/{districtid}")
    public R info(@PathVariable("districtid") Integer districtid) {
        TbDistrictEntity district = tbDistrictService.queryObject(districtid);

        return R.ok().put("district", district);
    }


}
